{include file="public/header" /}
<body class="gray-bg">
<div class="layui-fluid layui-col-md12">
    <div class="layui-card-body layui-form">
            <div class="layui-row layui-col-space10 layui-form-item ">
                    <input type="hidden" name="id" value="{$info.id}">
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">商家名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="sellor_name" lay-verify="required" placeholder="输入商家名称" class="layui-input " value="{$info.sellor_name}">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">商家手机号</label>
                    <div class="layui-input-block">
                        <input type="text" name="telephone" lay-verify="required" placeholder="输入商家名称" class="layui-input " value="{$info.telephone}">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">业务员姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" lay-verify="required" placeholder="输入业务员姓名" class="layui-input " value="{$info.username}">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">签约利率</label>
                    <div class="layui-input-block">
                        <input type="text" name="seller_pint" lay-verify="required" placeholder="输入签约利率" class="layui-input " value="{$info.seller_pint}">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">签约期数</label>
                    <div class="layui-input-block">
                        <select name="type" lay-verify="required" lay-search="请选择签约期数">
                            <option {eq name="$info.type" value="3"}selected{/eq}>3期</option>
                            <option {eq name="$info.type" value="6"}selected{/eq}>6期</option>
                            <option {eq name="$info.type" value="12"}selected{/eq}>12期</option>
                            <option {eq name="$info.type" value="24"}selected{/eq}>24期</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">支付方式</label>
                    <div class="layui-input-block">
                        <select name="support_type" lay-verify="required" lay-filter="test" lay-search="选择支付方式">
                            <option value="">选择支付方式</option>
                            <option {eq name="$info.support_type" value="1"}selected{/eq} value="1">寺库分期和乐百分分期</option>
                            <option {eq name="$info.support_type" value="2"}selected{/eq} value="2">寺库分期</option>
                            <option {eq name="$info.support_type" value="3"}selected{/eq} value="3">乐百分分期</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="s-app">
                        <label class="layui-form-label">寺库商户号</label>
                        <div class="layui-input-block">
                            <input type="text" name="s_appid"  placeholder="输入商户号" value="{$info.s_appid}" class="layui-input ">
                        </div>
                    </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="s-secret">
                    <label class="layui-form-label">寺库商户密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="s_secret" placeholder="输入商户密钥" value="{$info.s_secret}" class="layui-input ">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="le-app">
                        <label class="layui-form-label">乐百分商户号</label>
                        <div class="layui-input-block">
                            <input type="text" name="l_appid" placeholder="输入商户号" value="{$info.l_appid}" class="layui-input ">
                        </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="le-secret">
                    <label class="layui-form-label">乐百分商户密钥</label>
                    <div class="layui-input-block">
                        <input type="text" name="l_secret" value="{$info.l_secret}" placeholder="输入商户密钥" class="layui-input ">
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <label class="layui-form-label">商家简介</label>
                    <div class="layui-input-block">
                        <textarea name="store_desc" placeholder="输入商家简介" lay-verify="required" class="layui-textarea">{$info.store_desc}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                        </button>
                        <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
                    </div>
                </div>
            </div>
        </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            name:function(value,item){
                if(!/^[a-zA-Z_]*$/.test(value)){
                    return '只能使用英文和下划线且不能重复';
                }
                var checkResult = "";
                $.ajax({
                    url:"{:url('Config/checkConfig')}",
                    type:'post',
                    data:"name="+value + "&id=" + $('input[name=id]').val(),
                    async: false,//必须同步
                    success:function(res){
                        if(res.code == 100){
                            checkResult = "该配置标识已存在";
                        }
                    }
                })
                return checkResult;
            },
            extra: function(value,item){
                var type = $('#type').find("option:selected").text();
                if(type == "枚举" && value == ""){
                    return "配置类型为枚举，配置项必填";
                }
            },
            sort:[/^(0|[1-9]\d*)$/,'排序值只能为非负整数']
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('edit_config')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,'wk.layer_close()');
                    } else {
                        wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
        form.on('select(test)', function(data){
            if(data.value == '1'){
                $('#le-secret').css('display','block')
                $('#le-app').css('display','block')
                $('#s-secret').css('display','block')
                $('#s-app').css('display','block')
            }else if(data.value == '2'){
                $('#s-secret').css('display','block')
                $('#s-app').css('display','block')
                $('#le-secret').css('display','none')
                $('#le-app').css('display','none')
            }else if(data.value == '3'){
                $('#le-secret').css('display','block')
                $('#le-app').css('display','block')
                $('#s-secret').css('display','none')
                $('#s-app').css('display','none')
            }
        });
    });
</script>
</body>
</html>